const express =require('express') 
const path = require('path')
const fs =require('fs')
// 引入bodyParser 
const bodyParser = require("body-parser")
// const { urlencoded } = require('express')
const app =express()  

// 在app中注册bodyParser，使得app可以使用其内部函数
app.use(bodyParser.urlencoded({ extended:false })) 
app.use(bodyParser.json())

app.get("/",(req,res)=>{
    res.send("hello!!!!!!!!!")
})
app.get("/login",(req,res)=>{
    let url = path.join(__dirname,'views','login.html');
    let connet = fs.readFileSync(url,"utf-8");
    res.send(connet)
})
app.get("/index",(req,res)=>{
    let url = path.join(__dirname,'views','index.html');
    let connet = fs.readFileSync(url,"utf-8");
    res.send(connet)
})


app.post("/login",(req,res)=>{
    console.log(req.body);
    res.redirect("/index")
})

app.listen(3000,()=>{
    console.log('3000端口已启动！！！');
})